import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router';
import store from '../store';
import type { RouteRecordRaw } from 'vue-router';
const allRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/ProjectListView',
    component: () => import('@/layout/index.vue'),
    children: [
      {
        path: 'PersonalInformation',
        name: '个人中心',
        component: () => import('@/views/PersonalCenter/index.vue'),
        meta: {
          title: '个人中心',
          key: '个人中心',
          hidden: true
        }
      },
      {
        path: 'ProjectListView',
        name: 'ProjectListView',
        component: () => import('@/views/ProjectList/index.vue'),
        meta: {
          title: '我的项目',
          icon: 'project',
          hidden: false,
          key: 'ProjectListView'
        }
      },
      {
        path: 'CourseListView',
        name: 'CourseListView',
        component: () => import('@/views/CoursesList/index.vue'),
        meta: {
          title: '我的课程',
          icon: 'course',
          hidden: false,
          key: 'CourseListView'
        }
      }
    ]
  },
  {
    path: '/ProjectDetail/:projectId',
    name: '项目详情',
    component: () => import('@/views/ProjectDetails/index.vue'),
    redirect: '/ProjectDetail/:projectId/ProjectOerview',
    meta: {
      title: '项目详情',
      icon: 'group',
      roles: [1, 2, 3, 4],
      hidden: false,
      breadcrumb: false
    },
    children: [
      {
        path: 'ProjectOerview',
        name: '项目详情-项目概览',
        component: () => import('@/views/ProjectDetails/ProjectHomePage/index.vue'),
        meta: {
          title: '项目概览',
          roles: [1, 2, 3, 4],
          key: '项目详情-项目概览',
          icon: 'form',
          hidden: false
        }
      },
      {
        path: 'ProjectTasks',
        name: '项目详情-项目任务',
        component: () => import('@/views/ProjectDetails/ProjectTaskPage/index.vue'),
        meta: {
          title: '项目任务',
          roles: [1, 2, 3, 4],
          key: '项目详情-项目任务',
          hidden: false,
          icon: 'task'
        }
      },
      {
        path: 'ProjectDemand',
        name: '项目详情-项目产线',
        component: () => import('@/views/ProjectDetails/ProjectLinePage/index.vue'),
        meta: {
          title: '项目产线',
          roles: [1, 2, 3, 4],
          key: '项目详情-项目产线',
          hidden: false,
          icon: 'tool'
        }
      }
    ]
  },
  {
    path: '/CourseDetail/:courseId',
    name: '课程详情',
    component: () => import('@/views/CourseDetails/index.vue'),
    redirect: '/CourseDetail/:courseId/CourseDetailsHomePage',
    meta: {
      title: '课程详情',
      icon: 'group',
      hidden: false,
      breadcrumb: false
    },
    children: [
      {
        path: 'CourseDetailsHomePage',
        name: '课程详情-课程首页',
        component: () => import('@/views/CourseDetails/CourseHomePage/index.vue'),
        meta: {
          title: '课程首页',
          key: '课程详情-课程首页',
          icon: 'form',
          hidden: false
        }
      },
      {
        path: 'CourseProjectManagement',
        name: '课程详情-项目管理',
        component: () => import('@/views/CourseDetails/ProjectManagement/index.vue'),
        meta: {
          title: '项目管理',
          hidden: false,
          icon: 'project',
          key: '课程详情-项目管理'
        }
      },
      {
        path: 'ProjectOutcomes',
        name: '课程详情-任务成果',
        component: () => import('@/views/CourseDetails/TaskResults/index.vue'),
        meta: {
          title: '任务成果',
          key: '课程详情-任务成果',
          hidden: false
        }
      },
      {
        path: 'CourseTeamManagement',
        name: '课程详情-人员管理',
        component: () => import('@/views/CourseDetails/MemberManagement/index.vue'),
        meta: {
          title: '人员管理',
          icon: 'menuGroup',
          key: '课程详情-人员管理',
          hidden: false
        }
      },
      {
        path: 'ProjectOutcomesMan',
        name: '课程详情-成绩管理',
        component: () => import('@/views/CourseDetails/CourseGrades/index.vue'),
        meta: {
          title: '成绩管理',
          icon: '成绩',
          key: '课程详情-成绩管理',
          hidden: false
        }
      }
    ]
  }
];

// const { roles } = await store.dispatch('user/getInfo')
// const accessRoutes = await store.dispatch('permission/generateRoutes', roles)
const router = createRouter({
  history: createWebHashHistory(),
  routes: allRoutes
});

export default router;
